 
<script type="text/javascript">
function hideAddress(){
	if (
		$('input#billingAddress1').val() == $('input#address1').val() &&
		$('input#billingAddress2').val() == $('input#address2').val() &&
		$('input#billingAddress3').val() == $('input#address3').val() &&
		$('input#billingCity').val() == $('input#city').val() &&
		$('select#billingState').val() == $('select#state').val() &&
		$('input#billingPostcode').val() == $('input#postcode').val() &&
		$('select#billingCountry').val() == $('select#country').val()									
	){
		$('div#billing').hide();
		$('input#sameAddress').attr('checked', true);
	}
}
$(function(){
	$('a.showtab').click(function(event){
		event.preventDefault();
		var div = $(this).attr('href'); 
		$('div.tab').hide();
		$(div).show();
	});
	$('ul.innernav a').click(function(event){
		event.preventDefault();
		$(this).parent().siblings('li').removeClass('selected'); 
		$(this).parent().addClass('selected');
	});
	$('div.tab:not(#tab1)').hide();	
	$('input#sameAddress').click(function(){
		$('div#billing').toggle(200);
		$('input#billingAddress1').val($('input#address1').val());
		$('input#billingAddress2').val($('input#address2').val());
		$('input#billingAddress3').val($('input#address3').val());
		$('input#billingCity').val($('input#city').val());
		$('select#billingState').val($('select#state').val());
		$('input#billingPostcode').val($('input#postcode').val());
		$('select#billingCountry').val($('select#country').val());
	});
	hideAddress();


	$('input.save').click(function(){
		var requiredFields = 'input#productName, input#catalogueID';
		var success = true;
		$(requiredFields).each(function(){
			if (!$(this).val()) {
				$('div.panes').scrollTo(
					0, { duration: 400, axis: 'x' }
				);					
				$(this).addClass('error').prev('label').addClass('error');
				$(this).focus(function(){
					$(this).removeClass('error').prev('label').removeClass('error');
				});
				success = false;
			}
		});
		if (!success){
			$('div.tab').hide();
			$('div.tab:first').show();
		}
		return success;
	});
	
});
</script>

<form method="post" action="<?php echo site_url($this->uri->uri_string()); ?>" class="default">

<div class="container_topmenu">
	<div class="grid_12">
		<div class="grid_3">
			<h5>Edit User <small>(<a href="<?php echo site_url('/ssm/user'); ?>">Back to Users</a>)</small></h5>
		</div>
		<span class="topmenu">
			<?php ///if (in_array('users', $this->permission->permissions)): ?>

	<?php //endif; ?>

	<?php //if (in_array('users_groups', $this->permission->permissions)): ?>
	 	<input type="submit" value="Save Changes" class="button" />
			<?php // endif; ?>
			
	 </span>
	</div>
</div>

 <div class="container_12">
 
	<div class="grid_10">
	<?php if ($errors = validation_errors()): ?>
		<div class="error">
			<?php echo $errors; ?>
		</div>
	<?php endif; ?>
	<?php if (isset($message)): ?>
		<div class="message clear">
			<?php echo $message; ?>
		</div>
	<?php endif; ?>

	<ul class="innernav">
		<li class="selected"><a href="#tab1" class="showtab">Details</a></li>
		<?php //if (@in_array('shop', $this->permission->sitePermissions) || @in_array('community', $this->permission->sitePermissions)): ?>	
			<li><a href="#tab2" class="showtab">Address</a></li>
			<?php //if (@in_array('community', $this->permission->sitePermissions)): ?>
				<li><a href="#tab3" class="showtab">Other Info</a></li>
			<?php // endif; ?>
		<?php //p endif; ?>
	</ul>
 </div>
 
<div class="grid_12">
<div id="tab1" class="tab">

	<h4 style="color:#999;font-weight:normal;">User Details</h4>

	<label for="username">Username:</label>
	<?php echo @form_input('username', set_value('username', $data['username']), 'id="username" class="formelement"'); ?>
	<br class="clear" />

	<label for="password">Password:</label>
	<?php echo @form_password('password','', 'id="password" class="formelement"'); ?>
	<br class="clear" />

 
	<label for="permissions">Group:</label>
	<?php 
		$values = array(
			0 => 'None'
		);

		if ($this->session->userdata('groupID') == '-1')
		{
			$values[-1] = 'Superuser';
		}
		
		$values[$this->site->config['groupID']] = 'Administrator';
		if ($groups)
		{
			foreach($groups as $group)
			{
				$values[$group['groupID']] = $group['groupName'];
			}
		}
		echo @form_dropdown('groupID',$values,set_value('groupIDs', $data['groupID']), 'id="groupIDs" class="formelement"'); 
	?>
	<span class="tip">To edit permissions click on `User Groups` in the Users tab.</span>
	<br class="clear" />
 

	<label for="email">Email:</label>
	<?php echo @form_input('email',set_value('email', $data['email']), 'id="email" class="formelement"'); ?>
	<br class="clear" />	

	<label for="firstName">First Name:</label>
	<?php echo @form_input('firstName',set_value('firstName', $data['firstName']), 'id="firstName" class="formelement"'); ?>
	<br class="clear" />

	<label for="lastName">Last Name:</label>
	<?php echo @form_input('lastName',set_value('lastName', $data['lastName']), 'id="lastName" class="formelement"'); ?>
	<br class="clear" />

	<!-- label for="displayName">Display Name:</label> -->
	<?php //echo @form_input('displayName', set_value('displayName', $data['displayName']), 'id="displayName" class="formelement" maxlength="15"'); ?>
	<!--<span class="tip">For use in the forums (optional).</span><br class="clear" />-->

	<label for="active">Active?</label>
	<?php 
		$values = array(
			1 => 'Yes',
			0 => 'No'			
		);
		echo @form_dropdown('active',$values,set_value('active', $data['active']), 'id="active" class="formelement"'); 
	?>
	<br class="clear" />

<br />

</div>

<div id="tab2" class="tab">

<?php //if (@in_array('shop', $this->permission->sitePermissions) || @in_array('community', $this->permission->sitePermissions)): ?>	
	<h4 style="color:#999;font-weight:normal;">Delivery Address</h4>

	<label for="address1">Address 1:</label>
	<?php echo @form_input('address1',set_value('address1', $data['address1']), 'id="address1" class="formelement"'); ?>
	<br class="clear" />

	<label for="address2">Address 2:</label>
	<?php echo @form_input('address2',set_value('address2', $data['address2']), 'id="address2" class="formelement"'); ?>
	<br class="clear" />

	<label for="address3">Address 3:</label>
	<?php echo @form_input('address3',set_value('address3', $data['address3']), 'id="address3" class="formelement"'); ?>
	<br class="clear" />

	<label for="city">Tele 1:</label>
	<?php echo @form_input('tele1',set_value('tele1', $data['tele1']), 'id="tele1" class="formelement"'); ?>
	<br class="clear" />

	<label for="city">Tele 2:</label>
	<?php echo @form_input('tele2',set_value('tele2', $data['tele2']), 'id="tele2" class="formelement"'); ?>
	<br class="clear" />

	<label for="city">Tele 3:</label>
	<?php echo @form_input('tele3',set_value('tele3', $data['tele3']), 'id="tele3" class="formelement"'); ?>
	<br class="clear" />
 
<?php // endif; ?>

<br />
</div>

<div id="tab3" class="tab">

<?php //if (@in_array('community', $this->permission->permissions)): ?>

	<h4 style="color:#999;font-weight:normal;">Other Information</h4>

 	<label for="address1">Nick Name:</label>
	<?php echo @form_input('nickname',set_value('nickname', $data['nickname']), 'id="nickname" class="formelement"'); ?>
	<br class="clear" />	

 	<label for="student">Teacher:</label>
	<?php echo @form_input('teacher',set_value('teacher', $data['teacher']), 'id="teacher" class="formelement"'); ?>
	<br class="clear" />	

	<label for="address1">Position:</label>
	<?php echo @form_input('position',set_value('position', $data['position']), 'id="position" class="formelement"'); ?>
	<br class="clear" />	
	
	<label for="address1">Grade:</label>
	<?php 
		if ($grades)
		{
			$values=array();
			foreach($grades as $grade)
			{
				$values[$grade['section_id'].'_'.$grade['grade_id']] = $grade['label_'.$label_language];
			}
		}
	 	echo @form_dropdown('grades_id',$values,set_value('grades_id', $data['groupID']), 'id="grades_id" class="formelement"'); 
	?>
	<br class="clear" />	

 	<label for="address1">Room:</label>
	<?php echo @form_input('room',set_value('room', $data['room']), 'id="room" class="formelement"'); ?>
	<br class="clear" />	

 	<label for="address1">Facebook:</label>
	<?php echo @form_input('facebook',set_value('facebook', $data['facebook']), 'id="facebook" class="formelement"'); ?>
	<br class="clear" />	

   	<label for="address1">Parent Name:</label>
	<?php echo @form_input('parentname',set_value('parentname', $data['parentname']), 'id="parentname" class="formelement"'); ?>
	<br class="clear" />	

 	<label for="address1">Contact Person:</label>
	<?php echo @form_input('contactperson',set_value('contactperson', $data['contactperson']), 'id="contactperson" class="formelement"'); ?>
	<br class="clear" />
	
	<label for="address1">Congenital Disease:</label>
	<?php echo @form_input('congenitaldisease',set_value('congenitaldisease', $data['congenitaldisease']), 'id="congenitaldisease" class="formelement"'); ?>
	<br class="clear" />
			
 	<label for="image">Picture:</label>
	<div class="uploadfile">
		<?php if (isset($imagePath)):?>
			<img src="<?php echo $imagePath; ?>" alt="Personal Picture" />
		<?php endif; ?>
		<?php echo @form_upload('image',$this->validation->image, 'size="16" id="image"'); ?>
	</div>
	<br class="clear" />		
<?php //endif; ?>

<br />
</div>

 

<p class="clear" style="text-align: right;"><a href="#" class="button grey" id="totop">Back to top</a></p>
	
	</div>
</form>
 